package net.seehope.foodie.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.seehope.foodie.common.JsonResult;
import net.seehope.foodie.pojo.bo.CommentsBo;
import net.seehope.foodie.pojo.bo.SearchBo;
import net.seehope.foodie.pojo.bo.SearchByCatsBo;
import net.seehope.foodie.service.ItemService;

@Api("商品相关方法API")
@RestController
@RequestMapping("/items")
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	//参数的传入方式映射，直接使用bo对象进行传入
	@GetMapping("/search")
	public JsonResult renderSearchItem(SearchBo bo) {
		return JsonResult.isOk(itemService.renderSearchItem(bo));
	}
	
	@GetMapping("/catItems")
	public JsonResult renderSearchItem(SearchByCatsBo bo) {
		return JsonResult.isOk(itemService.renderSearchItem(bo));
	}
	
	
	@ApiOperation("渲染商品详情页面，包含四个对象")
	@GetMapping("/info/{itemId}")
	public JsonResult renderItemInfo(@PathVariable String itemId) {
		return JsonResult.isOk(itemService.renderItemInfo(itemId));
		
	}
	
	@ApiOperation("渲染商品评价等级数量")
	@GetMapping("/commentLevel")
	public JsonResult renderCommentLevelCounts(String itemId) {
		return JsonResult.isOk(itemService.renderCommentLevelCounts(itemId));
		
	}
	
	
	@ApiOperation("根据评论等级进行查询")
	@GetMapping("/comments")
	public JsonResult renderCommentsByLevel(CommentsBo bo) {
		return JsonResult.isOk(itemService.renderCommentsByLevel(bo));	
	}
	
	
	@ApiOperation("渲染购物车中的商品")
	@GetMapping("/refresh")
	public JsonResult renderShopCartItems(String itemSpecIds) {
		return JsonResult.isOk(itemService.renderShopCart(itemSpecIds));	
	}
	
	
	
	
}
